<script>
document.addEventListener('postchange', function (event) {
  console.log('postchange event', event);
});
function changeTab() {
  document.getElementById('tabbar').setActiveTab(1);
}
function changeButton() {
  document.getElementById('segment').setActiveButton(1);
}
function logIndexes() {
  console.log('active button index', document.getElementById('segment').getActiveButtonIndex());
  console.log('active tab index', document.getElementById('tabbar').getActiveTabIndex());
}
</script>

<ons-segment id="segment" tabbar-id="tabbar" style="width: 180px">
        <button>Page 1</button>
        <button>Page 2</button>
        <button>Page 3</button>
</ons-segment>